import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DeviceAlarmForm, DeviceAlarmQuery, DeviceAlarmVO } from './types';

/**
 * 查询告警信息列表
 * @param query
 * @returns {*}
 */

export const listDeviceAlarm = (query?: DeviceAlarmQuery): AxiosPromise<DeviceAlarmVO[]> => {
  return request({
    url: '/iot/deviceAlarm/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询告警信息详细
 * @param alarmId
 */
export const getDeviceAlarm = (alarmId: string | number): AxiosPromise<DeviceAlarmVO> => {
  return request({
    url: '/iot/deviceAlarm/' + alarmId,
    method: 'get'
  });
};

/**
 * 新增告警信息
 * @param data
 */
export const addDeviceAlarm = (data: DeviceAlarmForm) => {
  return request({
    url: '/iot/deviceAlarm',
    method: 'post',
    data: data
  });
};

/**
 * 修改告警信息
 * @param data
 */
export const updateDeviceAlarm = (data: DeviceAlarmForm) => {
  return request({
    url: '/iot/deviceAlarm',
    method: 'put',
    data: data
  });
};

/**
 * 删除告警信息
 * @param alarmId
 */
export const delDeviceAlarm = (alarmId: string | number | Array<string | number>) => {
  return request({
    url: '/iot/deviceAlarm/' + alarmId,
    method: 'delete'
  });
};
